package com.shadow.baiqun.delegate.receive.adapter;

import android.graphics.Color;
import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.shadow.baiqun.R;
import com.shadow.ui.recycler.MultipleItemEntity;

import java.util.List;

/**
 * @author zy
 * on 2018/5/29
 */
public class PartCheckAdapter extends BaseQuickAdapter<MultipleItemEntity, BaseViewHolder> {
    private int mStateColorNotScan;
    private int mStateHadScan;

    public PartCheckAdapter(int layoutResId, @Nullable List<MultipleItemEntity> data) {
        super(layoutResId, data);
        mStateHadScan = Color.GREEN;
        mStateColorNotScan = Color.RED;
    }

    @Override
    protected void convert(BaseViewHolder helper, MultipleItemEntity item) {
        helper.setText(R.id.tv_stock_name, (CharSequence) item.getField(ItemName.ITEM_LOCATION));
        helper.setText(R.id.tv_bord_code, (CharSequence) item.getField(ItemName.ITEM_PART_CODE));
        helper.setText(R.id.tv_part_name, (CharSequence) item.getField(ItemName.ITEM_PART_NAME));
        helper.setText(R.id.tv_count, (CharSequence) item.getField(ItemName.ITEM_PART_COUNT));
        String state = item.getField(ItemName.ITEM_STATE);
        if ("1".equals(state)) {
            helper.setText(R.id.tv_state, "已扫描");
            helper.setTextColor(R.id.tv_state, mStateHadScan);
        } else if ("2".equals(state)) {
            helper.setText(R.id.tv_state, "已核对");
            helper.setTextColor(R.id.tv_state, mStateHadScan);
        } else {
            helper.setText(R.id.tv_state, "未扫描");
            helper.setTextColor(R.id.tv_state, mStateColorNotScan);
        }
        helper.addOnClickListener(R.id.btn_scan);
    }
}
